<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p><input type="checkbox">苹果</p>
    <p><input type="checkbox">西瓜</p>
    <p><input type="checkbox">香蕉</p>

    <p class="info"></p>

    <script>
        // 1 获取元素
        var inp = document.querySelectorAll("p input")
        // 获取到显示的内容
        var info = document.querySelector(".info")
        // 遍历每一个input
        for(var i = 0;i <length;i++){
            inp[i].onchange = function(){
                // alert(1) innerHTML 写入相应的内容
                info.innerHTML += this.value
            }
        }
    </script>
</body>
</html>